#ifndef NANO2_H
#define NANO2_H

#include "ui_nano2.h"

#include <QtGui/QMainWindow>
#include <QColorGroup>
#include <QColor>
#include <QTimer>
#include <QDial>
#include <QValidator>
#include <QMdiSubWindow>
#include <qwt_plot.h>

#include "AudioCaptureWidget.h"
#include "SerialWidget.h"
#include "editPlotWindow.h"



class nano2 : public QMainWindow
{
    Q_OBJECT

public:
    nano2(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~nano2();

    // stepSizeStr = step size number
    QString stepSizeStr;
    QString stepSize;
    QString move;
    QString noofStepsA;
    QString noofStepsB;
    QString noofStepsC;
    QString joint;
    QString dir;
    QString command;

    // looptime
    int loopTime;

    // flag to indicate port initialization
    int init;

    // serial port object
    SerialWidget *port;

    // mic object
    AudioCaptureWidget *mic;

    // timer to keep track of number of steps
    QTimer *timer;

    // validator to validate input data in the form
    QValidator *validator;

    // subwindow for threshold data
    QMdiSubWindow thresholdData;

    //  plot edit window
    editPlotWindow *e;


private:
    Ui::nano2Class ui;

    // switch status
    int status;

    // int to count number of steps
    int stepCountA;
    int stepCountB;
    int stepCountC;

    // send step size command to serial port
    void setStepSize();



    // manipulator enable flag
    int enableManip;


signals:
    // returns number of steps taken
    void countA(int);
    void countB(int);
    void countC(int);

public slots:
    // move joint by number of steps
    void moveJoint();

    // functions for corresponding buttons to control motion of joints
    void jt1Clk();
    void jt1Aclk();
    void jt2Clk();
    void jt2Aclk();
    void jt3Out();
    void jt3In();


    // stop trial
    void stopButton();

    // reset counters
    void resetA();
    void resetB();
    void resetC();

    // set no. of steps per cycle
    void setNoOfStepsC();
    void setNoOfStepsB();
    void setNoOfStepsA();

    // sets stopthreshold value
    void setThreshold();

    // functions for actions
    void actionOpen();
    void actionClose();


    // slot for plot edit
    void plotEdit();

    // update plot axis
    void updatePlotAxis();

    // update manipulator enable check state
    void setEnableManip();



};

#endif // NANO2_H
